package com.lq.order.exception;

import com.lq.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理订单异常
     */
    @ExceptionHandler(OrderException.class)
    @ResponseBody
    public Result handleOrderException(OrderException e) {
        return Result.failed(e.getMessage());
    }

    /**
     * 处理其他异常
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handleException(Exception e) {
        return Result.failed(e.getMessage());
    }
}